package ycl.schedule.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ycl.common.base.controller.BaseController;
import ycl.common.models.base.A;
import ycl.common.result.Result;
import ycl.schedule.entity.Schedule;
import ycl.schedule.req.ScheduleReq;
import ycl.schedule.res.ScheduleRes;
import ycl.schedule.service.ScheduleService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * <p>
 * 用户日程 前端控制器
 * </p>
 *
 * @author ycl
 * @since 2022-06-23 20:21:11
 */
@RestController
@RequestMapping("/schedule")
@Api(tags = "日程")
public class ScheduleController
		extends BaseController<Schedule, ScheduleReq, ScheduleRes> {

	@Resource
	private ScheduleService scheduleService;

	@Override
	public Result<Page<ScheduleRes>> pageList(HttpServletRequest request,Schedule schedule) {
		return Result.success(scheduleService.pageList(request, schedule, ScheduleRes.class));
	}

	@Override
	public Result<Schedule> getById(HttpServletRequest request, Long id) {
		return Result.success(scheduleService.getById(request, id, Schedule.class));
	}

	@Override
	public <E extends ScheduleReq> Result<A> save(HttpServletRequest request, @Valid E e) {
		scheduleService.save(request, e, Schedule.class);
		return Result.success();
	}

	@Override
	public <E extends ScheduleReq> Result<A> update(HttpServletRequest request, @Valid E e) {
		scheduleService.update(request, e, Schedule.class);
		return Result.success();
	}
}

